﻿// Waiting Dialog

function WAITINGDLG_init(pIMG) {
  var divWaiting = document.getElementById("waitingDlg");
  if (divWaiting == null) {
    divWaiting = document.createElement("div");
    divWaiting.id = "waitingDlg";

    var div1 = document.createElement("div");
    divWaiting.insertBefore(div1, divWaiting.firstChild);
    var spnCaption = document.createElement("span");
//    if (isThai()) {
      spnCaption.innerText = " กรุณารอสักครู่ ...";
//    } else {

//   }
//   spnCaption.innerText = " Please wait to process data ...";
   div1.insertBefore(spnCaption, div1.firstChild);
    
    var imgHourglass = document.createElement("img");
    imgHourglass.src = pIMG;
    imgHourglass.align = "absmiddle";
    div1.insertBefore(imgHourglass, div1.firstChild);
  
    // if IE, insert iframe shim to fix select overlap bug
    if (window.attachEvent) {
      var iframe1 = document.createElement("iframe");
      divWaiting.insertBefore(iframe1, divWaiting.firstChild);
    }

   var theBody = document.getElementsByTagName("body")[0];
    theBody.insertBefore(divWaiting, theBody.firstChild);
  }
  return divWaiting;
}

function WAITINGDLG_show(pIMG) {
   var divWaiting = WAITINGDLG_init(pIMG);
  if (divWaiting) {
    if (window.event) {
      // if IE
      if (document.documentElement) {
        // IE standard mode
        divWaiting.style.left = document.documentElement.scrollLeft + window.event.clientX - (divWaiting.clientWidth / 2) + "px";
        divWaiting.style.top = document.documentElement.scrollTop + window.event.clientY - (divWaiting.clientHeight / 2) + "px";
        divWaiting.style.visibility = "visible";
      } else if (document.body) {
        // IE quirk mode
        divWaiting.style.left = document.body.scrollLeft + window.event.clientX - (divWaiting.clientWidth / 2) + "px";
        divWaiting.style.top = document.body.scrollTop + window.event.clientY - (divWaiting.clientHeight / 2) + "px";
        divWaiting.style.visibility = "visible";
      }
    }
  }
}

function WAITINGDLG_hide() {
  var divWaiting = document.getElementById("waitingDlg");
  if (divWaiting) {
    divWaiting.style.visibility = "hidden";
  }
}

/*
// hook to window's load event
if (window.addEventListener) {	// if DOM's compliant browser
  window.addEventListener("load", WAITINGDLG_init, false);
} else if (window.attachEvent) {  // if IE
  window.attachEvent("onload", WAITINGDLG_init);
}
*/